﻿document.writeln("<script src='\/stylewap\/js\/ajax.js'><\/script>");

function showlogin(){//顶部登录框判断是否登录
	doAjax("/wapajax.php", "showlogin=1", "showlogin2", "GET", 0);
}
function showlogin2(t){//顶部登录框判断是否登录
	login_top = document.getElementById("login_top");
	if(t != "nologin"){
		login_top.innerHTML = "<div onclick='show_bookcase()' style='max-width:90px;overflow:hidden;height:50px;padding:0px 10px;' class='c_index_top'>" + t + "<\/div>";
	}
}
function show_bookcase(){
	info = document.getElementById("info");
	if(info.style.display == "block"){
		info.style.display = "none";	
	}
	else{
		info.style.display = "block";	
	}
}


function login(){//开启登录
	uname = document.getElementById("username").value;
	upass = document.getElementById("userpass").value;

    doAjax("/waplogin.php", "chname=" + uname + "&chpass=" + upass, "go_login", "POST", 0);
}

function go_login(t){
	//alert(decodeURIComponent(t));
	doAjax("/wapajax.php", "is_login=1", "is_login", "GET", 0);
}

function is_login(t){
	if(t == "right"){
		document.getElementById("logintips").innerHTML = "登录成功！";
		var urlarray= new Array(); //定义一数组
		urlarray = document.URL.split("?url="); //字符分割
		url = urlarray[1]; 
		if(url){
			url = url.replace(/\%2F/g,"/");
			url = url.replace(/\%3A/g,":");
			url = url.replace(/\%23/g,"");
			url = url.replace(/\%3F/g,"?");
			url = url.replace(/\%3D/g,"=");
			url = url.replace(/\%26/g,"&");
			window.location.href = url;	
		}
		else{
			window.location.href = "/";	
		}
		
		
	}
	else{
		document.getElementById("logintips").innerHTML = "帐号或密码错误，登录失败！";	
	}
}
//退出登录
function logout(){
	doAjax("/logout.php", "t=1", "logout2", "GET", 0);	
}
function logout2(){
	window.location.href = "/";
}
function register(){
	uname = document.getElementById("regname").value;
	upass = document.getElementById("regpass").value;
	uemail = document.getElementById("regemail").value;
	doAjax("/wapregister.php", "uname=" + uname + "&upass=" + upass + "&uemail=" + uemail, "go_register", "POST", 0);
}
function go_register(t){
	tips = document.getElementById("logintips");	
	if(t == "nodata"){
		tips.innerHTML = "以上信息都必须输入";	
	}
	if(t == "bigname"){
		tips.innerHTML = "用户名太长！10个中问或者30个英文以内！";	
	}	
	if(t == "bigpass"){
		tips.innerHTML = "密码太长！16位以内！";	
	}	
	if(t == "bigemail"){
		tips.innerHTML = "邮箱太长！";	
	}	
	if(t == "emailerror"){
		tips.innerHTML = "邮箱格式错误！";	
	}
	if(t == "havename"){
		tips.innerHTML = "用户名已被注册！";	
	}
	if(t == "haveemial"){
		tips.innerHTML = "邮箱已被注册！";	
	}
	if(t == "yesregister"){
		tips.innerHTML = "注册成功并已经登录！";
		window.location.href = "/";	
	}		
}

function bookcaseurl(){
	doAjax("/wapajax.php", "bookcase=1", "bookcaseurl2", "GET", 0);
}

function case_del(aid,articlename){
	//alert(aid);
	doAjax("/addbookcase.php", "dopost=del&bid=" + aid + "&articlename="+articlename, "case_del2", "GET", 0);
	document.getElementById("" + aid).innerHTML = "<tr><td style='height:30px;line-height:30px;'><font color=red>删除中，请稍后...</font></td></tr>";
}
function case_del2(t){
	//alert(t);
	if(t != ""){
		table = document.getElementById("" + t);
		table.style.backgroundColor = "#D3FEDA";
		
		table.innerHTML = "<tr><td style='height:30px;line-height:30px;'><font color=red>已从书架删除！</font></td></tr>";
		
	}
}

function shuqian(aid,cid){
	//alert("shuqian");	
	doAjax("/addbookcase.php", "dopost=shuqian&bid=" + aid + "&cid=" + cid, "shuqian2", "GET", 0);
}
function shuqian2(t){
	if (t == 'succ')
	{
		alert('成功加入书签！');
		exit;
	}
	if (t == 'update')
	{
		alert('成功更新书签！');
		exit;
	}
	if (t == 'error')
	{
		alert('已加入书签中！');
		exit;
	}
	
	else {
		alert('请登陆，跳转到登陆页面...');
		//window.location.href = "/login.html";
		exit;
	}
}

function shujia(aid,articlename){
	//alert("shujia");	
	doAjax("/addbookcase.php", "dopost=shujia&bid=" + aid + "&articlename="+articlename, "shujia2", "GET", 0);
}
function shujia2(t){
	//alert(t);
	if (t == 'succ')
	{
		alert('成功加入书架！');
		exit;
	}

	if (t == 'error')
	{
		alert('已加入书架中！');
		exit;
	}

}

function show_search(){
	
	var type = document.getElementById("type");
	var searchType = document.getElementById("searchType");
	if(type.innerHTML == "书名"){
		type.innerHTML = "作者";
		searchType.value = "author";
		//alert(searchType.value);
	}
	else{
		type.innerHTML = "书名";
		searchType.value = "articlename";
	}
}

function allchapter2(t){
	document.getElementById("chapter_load").style.display = "none";
	document.getElementById("all_chapter").innerHTML = t ;
}



//alert(document.cookie);
//exit;

var checkbg = "#A7A7A7";
//内容页用户设置
function nr_setbg(intype){
	var huyandiv = document.getElementById("huyandiv");
	var light = document.getElementById("lightdiv");
	if(intype == "huyan"){
		if(huyandiv.style.backgroundColor == ""){
			document.cookie="light=huyan;path=/"; 
			set("light","huyan");
		}
		else{
			document.cookie="light=no;path=/"; 
			set("light","no");
		}
	}
	if(intype == "light"){
		if(light.innerHTML == "关灯"){
			document.cookie="light=yes;path=/";
			set("light","yes");
		}
		else{
			document.cookie="light=no;path=/"; 
			set("light","no");
		}
	}
	if(intype == "big"){
		document.cookie="font=big;path=/";
		set("font","big");
	}
	if(intype == "middle"){
		document.cookie="font=middle;path=/"; 
		set("font","middle");
	}
	if(intype == "small"){
		document.cookie="font=small;path=/"; 
		set("font","small");
	}		
}

//内容页读取设置
function getset(){ 
	var strCookie=document.cookie; 
	var arrCookie=strCookie.split("; ");  
	var light;
	var font;

	for(var i=0;i<arrCookie.length;i++){ 
		var arr=arrCookie[i].split("="); 
		if("light"==arr[0]){ 
			light=arr[1]; 
			break; 
		} 
	} 

	//light
	if(light == "yes"){
		set("light","yes");
	}
	else if(light == "no"){
		set("light","no");
	}
	else if(light == "huyan"){
		set("light","huyan");
	}
}


//内容页读取设置
function getset1(){ 
	var strCookie=document.cookie; 
	var arrCookie=strCookie.split("; ");  
	var light;
	var font;

	for(var j=0;j<arrCookie.length;j++){ 
		var arr=arrCookie[j].split("="); 
		if("font"==arr[0]){ 
			font=arr[1]; 
			break; 
		} 
	} 

	//font
	if(font == "big"){
		set("font","big");
	}
	else if(font == "middle"){
		set("font","middle");
	}
	else if(font == "small"){
		set("font","small");
	}
	else{
		set("","");	
	}
}

//内容页应用设置
function set(intype,p){
	var nr_body = document.getElementById("nr_body");//页面body
	var huyandiv = document.getElementById("huyandiv");//护眼div
	var lightdiv = document.getElementById("lightdiv");//灯光div
	var fontfont = document.getElementById("fontfont");//字体div
	var fontbig = document.getElementById("fontbig");//大字体div
	var fontmiddle = document.getElementById("fontmiddle");//中字体div
	var fontsmall = document.getElementById("fontsmall");//小字体div
	var nr1 =  document.getElementById("nr1");//内容div
	var nr_title =  document.getElementById("nr_title");//文章标题
	//var nr_title =  document.getElementById("nr_title");//文章标题
	var shuqian_2 = document.getElementById("shuqian_2");//书签链接
	
	var pt_prev =  document.getElementById("pt_prev");
	var pt_mulu =  document.getElementById("pt_mulu");
	var pt_next =  document.getElementById("pt_next");
	var pb_prev =  document.getElementById("pb_prev");
	var pb_mulu =  document.getElementById("pb_mulu");
	var pb_next =  document.getElementById("pb_next");
	
	//初始化
	//document.getElementsByName("page_nr")[1].style.color = "#000";
	
	//灯光
	if(intype == "light"){
		if(p == "yes"){	
			//关灯
			lightdiv.innerHTML = "开灯";
			nr_body.style.backgroundColor = "#000";
			huyandiv.style.backgroundColor = "";
			nr_title.style.color = "#ccc";
			nr1.style.color = "#999";
			pt_prev.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			pt_mulu.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			pt_next.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			pb_prev.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			pb_mulu.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			pb_next.style.cssText = "background-color:#222;color:#0065B5;border:1px solid #0065B5";
			shuqian_2.style.color = "#999";
		}
		else if(p == "no"){
			//开灯
			lightdiv.innerHTML = "关灯";
			nr_body.style.backgroundColor = "#fff";
			nr1.style.color = "#000";
			nr_title.style.color = "#000";
			huyandiv.style.backgroundColor = "";
			pt_prev.style.cssText = "";
			pt_mulu.style.cssText = "";
			pt_next.style.cssText = "";
			pb_prev.style.cssText = "";
			pb_mulu.style.cssText = "";
			pb_next.style.cssText = "";
			shuqian_2.style.color = "#000";
		}
		else if(p == "huyan"){
			//护眼
			lightdiv.innerHTML = "关灯";
			huyandiv.style.backgroundColor = checkbg;
			nr_body.style.backgroundColor = "#005716";
			nr1.style.color = "#000";
			pt_prev.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			pt_mulu.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			pt_next.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			pb_prev.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			pb_mulu.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			pb_next.style.cssText = "background-color:#0E7A18;color:#000;border:1px solid #0065B5";
			shuqian_2.style.color = "#000";
		}
	}
	//字体
	if(intype == "font"){
		//alert(p);
		fontbig.style.backgroundColor = "";
		fontmiddle.style.backgroundColor = "";
		fontsmall.style.backgroundColor = "";
		if(p == "big"){
			fontbig.style.backgroundColor = checkbg;
			nr1.style.fontSize = "25px";
		}
		if(p == "middle"){
			fontmiddle.style.backgroundColor = checkbg;
			nr1.style.fontSize = "15px";
		}
		if(p == "small"){
			fontsmall.style.backgroundColor = checkbg;
			nr1.style.fontSize = "12px";
		}
	}
}

//广告开始
function cnzz(){
document.writeln("<div style=\"display:none\" >");
document.writeln("<script type=\"text/javascript\">var cnzz_protocol = ((\"https:\" == document.location.protocol) ? \" https://\" : \" http://\");document.write(unescape(\"%3Cspan id=\'cnzz_stat_icon_1255416576\'%3E%3C/span%3E%3Cscript src=\'\" + cnzz_protocol + \"s4.cnzz.com/z_stat.php%3Fid%3D1255416576\' type=\'text/javascript\'%3E%3C/script%3E\"));</script>");
document.writeln("</div>");
}
function tj(){
document.writeln("<div style=\"display:none\" >");
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fb1ed580e5bd53b17fdefc52983be95ec' type='text/javascript'%3E%3C/script%3E"));
document.writeln("</div>");
}
function shipei_1(){
document.writeln("<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>");
document.writeln("<!-- 320x100-1 -->");
document.writeln("<ins class=\"adsbygoogle\"");
document.writeln("     style=\"display:inline-block;width:320px;height:100px\"");
document.writeln("     data-ad-client=\"ca-pub-7534302956628937\"");
document.writeln("     data-ad-slot=\"2517919003\"></ins>");
document.writeln("<script>");
document.writeln("(adsbygoogle = window.adsbygoogle || []).push({});");
document.writeln("</script>");
}
function shipei_2(){
document.writeln("<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>");
document.writeln("<!-- 320x50-1 -->");
document.writeln("<ins class=\"adsbygoogle\"");
document.writeln("     style=\"display:inline-block;width:320px;height:50px\"");
document.writeln("     data-ad-client=\"ca-pub-7534302956628937\"");
document.writeln("     data-ad-slot=\"5471385409\"></ins>");
document.writeln("<script>");
document.writeln("(adsbygoogle = window.adsbygoogle || []).push({});");
document.writeln("</script>");
}
function shipei_3(){
document.writeln("<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>");
document.writeln("<!-- shipei-2 -->");
document.writeln("<ins class=\"adsbygoogle\"");
document.writeln("     style=\"display:block\"");
document.writeln("     data-ad-client=\"ca-pub-7534302956628937\"");
document.writeln("     data-ad-slot=\"4380751003\"");
document.writeln("     data-ad-format=\"auto\"></ins>");
document.writeln("<script>");
document.writeln("(adsbygoogle = window.adsbygoogle || []).push({});");
document.writeln("</script>");
}